cmake_minimum_required(VERSION 3.10)
project(MyProject              # 工程名
        VERSION 1.0
        DESCRIPTION "A tiny C++ demo"
        LANGUAGES CXX)         # 声明语言为 C++

# C++ 标准
set(CMAKE_CXX_STANDARD 17)     # 用 C++17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# 可执行文件
add_executable(myapp
    src/main.cpp
    src/utils.cpp
)

# 头文件搜索路径
target_include_directories(myapp PRIVATE include)

# 链接系统库
# 如果 utils 里用到了 <cmath> 里的函数，照样可以链接 libm
target_link_libraries(myapp PRIVATE m)

# 可选：若开启警告
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    target_compile_options(myapp PRIVATE -Wall -Wextra -pedantic)
endif()